#include "SequenceWorker.h"

SequenceWorker::SequenceWorker(QObject *parent) :
   QThread(parent),
   isRunning(true)
{
   // Blank intentionally
}

void SequenceWorker::quit()
{
   isRunning = false;
}

void SequenceWorker::addSequence(Sequence sequence)
{
   theSequences.append(sequence);
}

void SequenceWorker::run()
{
   if(isRunning)
   {
      foreach(Sequence sequence, theSequences)
      {
         QList<Entry> entries = sequence.entries();

         foreach(Entry entry, entries)
         {
            emit signalSetColor(entry.led(), entry.color());
            QThread::msleep(entry.delayMs());
         }
      }
   }
}
